package com.neusoft.care.controller;


import com.neusoft.care.po.CareLevel;
import com.neusoft.care.po.ClientCareSetting;
import com.neusoft.care.po.ResponseBean;
import com.neusoft.care.service.ClientCareSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
//@CrossOrigin("*")
@RequestMapping("/ClientCareSettingController")
public class ClientCareSettingController {

    @Autowired
    private ClientCareSettingService clientCareSettingService;

    @GetMapping
    public ResponseBean<List<ClientCareSetting>> getAllClientCareSettings() {
        return clientCareSettingService.getAllClientCareSettings();
    }

    @GetMapping("/{id}")
    public ResponseBean<ClientCareSetting> getClientCareSettingById(@PathVariable Integer id) {
        return clientCareSettingService.getClientCareSettingById(id);
    }

    @GetMapping("/getClientCareSettingByClientId")
//    根据客户id查询客户护理级别信息
    public ResponseBean<CareLevel> getClientCareSettingByClientId(@RequestParam Integer id) {
        return clientCareSettingService.getClientCareSettingByClientId(id);
    }

    @PostMapping("/addClientCareSetting")
//    给客户设置护理级别
    public ResponseBean<Integer> addClientCareSetting(@RequestBody ClientCareSetting setting) {
        return clientCareSettingService.addClientCareSetting(setting);
    }

    @PutMapping("/updateClientCareSetting")
//    修改客户的护理级别（传入客户id和级别id）
    public ResponseBean<Integer> updateClientCareSetting(
            @RequestBody ClientCareSetting setting) {
        return clientCareSettingService.updateClientCareSetting(setting);
    }

    @DeleteMapping("/deleteClientCareSetting")
//    移除客户的护理级别，同时级联删除客户的护理项目
    public ResponseBean<Integer> deleteClientCareSetting(@RequestParam Integer clientId) {
        return clientCareSettingService.deleteClientCareSetting(clientId);
    }
}